﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/ezdesk_app_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="pageTitle" -->
    <title>易得桌面</title>
    <!-- InstanceEndEditable -->
<link href="Content/jquery-ui.custom.css" rel="stylesheet" type="text/css" />
<link href="Content/ui.textbox.css" type="text/css" rel="stylesheet"  media="all" />
<link href="Content/freecontent.css" rel="stylesheet" type="text/css" />
<link href="Content/wdatepicker.css" rel="stylesheet" type="text/css" />
<link href="Content/ajaxbusy.css" rel="stylesheet" type="text/css" />
<link href="Content/Site.css" rel="stylesheet" type="text/css" />

<script src="Scripts/ezdesk_mockdata.js" type="text/javascript"></script>
<script src="Scripts/jquery.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui.custom.min.js" type="text/javascript"></script>   
<script src="Scripts/jquery.form.js" type="text/javascript"></script>
<script src="Scripts/ui.textbox.js" type="text/javascript"></script>
<script src="Scripts/pinyin.js" type="text/javascript"></script>
    <script src="Scripts/ezdesk-jquery-ui.js" type="text/javascript"></script>
    <script src="Scripts/ezdesk_common.js" type="text/javascript"></script>
</head>

<!-- InstanceBeginEditable name="pageStyles" -->
    <style type="text/css">
        
    </style>
    <!-- InstanceEndEditable -->
    
<!-- InstanceBeginEditable name="pageScripts" -->
<script language="javascript" type="text/javascript">
    //************* URL常量

    var URL_LEAVE_INFOLIST_FORAUDIT = '/attendance/LeaveInfoListForAudit';

    //************* 全局变量

    var g_Var = {
        'currentUser': null,
        'leaveInfoList': null,
        'defaultChecked': false
    };

    //************* 常量定义

    var StaticResource = {
        'true': '已审核',
        'false': '未审核',
        'operation': '进行审核'
    }

    var convertor = {
        "申请人": function (item) {
            return item.User.Name;
        },
        "申请时间": function (item) {
            return Date.fromEpoch(item.CreateTime).toChineseDateFormat()
                        + "<br />"
                        + Date.fromEpoch(item.CreateTime).toFullTimeFormat();
        },
        "起始时间": function (item) {
            return toFullTimeWithoutSecond(item.StartTime)
                        + "<br />"
                        + "至"
                        + "&nbsp;"
                        + toFullTimeWithoutSecond(item.EndTime);
        },
        "请假类型": function (item) {
            return item.LeaveTypeName;
        },
        "状态": function (item) {

            if (item.IsAudited == false) {
                var IsAudited = '<p style="color:red;">{IsAudited}</p>';
                IsAudited = IsAudited.replace("{IsAudited}", StaticResource[item.IsAudited]);
            }
            else {
                var IsAudited = '<p >{IsAudited}</p>';
                IsAudited = IsAudited.replace("{IsAudited}", StaticResource[item.IsAudited]);
            }

            return IsAudited;
        },
        "操作": function (item) {
            var className = "aLinkClass";
            return '<a ' + 'id="' + item.Id + '" class="' + className + '">进行审核</a>';
        }
    };

    //************* Accessor访问器

    var EzAccessor = {};

    if (ezmock.IS_MOCKED) {

        var mock_currentUser =
        { "Id": "0c9d7c0c-04a5-4ae2-97a1-d7bbc38f5c66",
            "Name": "杨裕欣", "UserName": "yuxin",
            "Dept": {
                "Id": "bd3474a8-6c2d-43ef-bf42-b06827a216f6",
                "DeptName": "软件工程部",
                "GroupId": "9ad96dac-88d8-4315-bfdb-9931c8f3cb7c"
            }
        };

        var mock_leaveInfoList = { 'leaveInfoList':
                        [{ "Id": "480f8836-29a9-4ba6-bbe1-8a3e928fc5de",
                            "LeaveTypeId": "c7615898-2739-4c33-a8dc- a1451537b170",
                            "LeaveTypeName": "外出",
                            "User": {
                                "Id": "ce36c495-38cc-4b7e-875e-364ff8e087b5",
                                "Name": "卢春叶",
                                "UserName": "lcy",
                                "Dept": {
                                    "Id": "e8731583-3397-4f28-aa43-c006dbe750a2",
                                    "DeptName": "行政部",
                                    "GroupId": "c875149c-ee0c-48e2-bd2d-39d870f49b67"
                                }
                            },
                            "CreateTime": "1238413000",
                            "StartTime": "1238463000",
                            "EndTime": "1238468400",
                            "Description": " 小东门银行",
                            "IsAudited": false,
                            "AuditUser": { "Name": "王晓" },
                            "AuditNote": "asdasdasd",
                            "AuditTime": "1282010290",
                            "IsForWork": false,
                            "IsAgreed": false
                        },
                        { "Id": "480f8836-29a9-4ba6-bbe1-8a3e928fc5de",
                            "LeaveTypeId": "c7615898-2739-4c33-a8dc- a1451537b170",
                            "LeaveTypeName": "外出",
                            "User": {
                                "Id": "ce36c495-38cc-4b7e-875e-364ff8e087b5",
                                "Name": "卢春叶",
                                "UserName": "lcy",
                                "Dept": {
                                    "Id": "e8731583-3397-4f28-aa43-c006dbe750a2",
                                    "DeptName": "行政部",
                                    "GroupId": "c875149c-ee0c-48e2-bd2d-39d870f49b67"
                                }
                            },
                            "CreateTime": "1238413000",
                            "StartTime": "1238463000",
                            "EndTime": "1238468400",
                            "Description": " 小东门银行",
                            "IsAudited": false,
                            "AuditUser": { "Name": "王晓" },
                            "AuditNote": "asdasdasd",
                            "AuditTime": "1282010290",
                            "IsForWork": false,
                            "IsAgreed": false
                        },
                        { "Id": "480f8836-29a9-4ba6-bbe1-8a3e928fc5de",
                            "LeaveTypeId": "c7615898-2739-4c33-a8dc- a1451537b170",
                            "LeaveTypeName": "外出",
                            "User": {
                                "Id": "ce36c495-38cc-4b7e-875e-364ff8e087b5",
                                "Name": "卢春叶",
                                "UserName": "lcy",
                                "Dept": {
                                    "Id": "e8731583-3397-4f28-aa43-c006dbe750a2",
                                    "DeptName": "行政部",
                                    "GroupId": "c875149c-ee0c-48e2-bd2d-39d870f49b67"
                                }
                            },
                            "CreateTime": "1238413000",
                            "StartTime": "1238463000",
                            "EndTime": "1238468400",
                            "Description": " 小东门银行",
                            "IsAudited": false,
                            "AuditUser": { "Name": "王晓" },
                            "AuditNote": "asdasdasd",
                            "AuditTime": "1282010290",
                            "IsForWork": false,
                            "IsAgreed": false
                        },
                        { "Id": "480f8836-29a9-4ba6-bbe1-8a3e928fc5de",
                            "LeaveTypeId": "c7615898-2739-4c33-a8dc- a1451537b170",
                            "LeaveTypeName": "外出",
                            "User": {
                                "Id": "ce36c495-38cc-4b7e-875e-364ff8e087b5",
                                "Name": "卢春叶",
                                "UserName": "lcy",
                                "Dept": {
                                    "Id": "e8731583-3397-4f28-aa43-c006dbe750a2",
                                    "DeptName": "行政部",
                                    "GroupId": "c875149c-ee0c-48e2-bd2d-39d870f49b67"
                                }
                            },
                            "CreateTime": "1238413000",
                            "StartTime": "1238463000",
                            "EndTime": "1238468400",
                            "Description": " 小东门银行",
                            "IsAudited": false,
                            "AuditUser": { "Name": "王晓" },
                            "AuditNote": "asdasdasd",
                            "AuditTime": "1282010290",
                            "IsForWork": false,
                            "IsAgreed": false
                        }, { "Id": "480f8836-29a9-4ba6-bbe1-8a3e928fc5de",
                            "LeaveTypeId": "c7615898-2739-4c33-a8dc- a1451537b170",
                            "LeaveTypeName": "外出",
                            "User": {
                                "Id": "ce36c495-38cc-4b7e-875e-364ff8e087b5",
                                "Name": "卢春叶",
                                "UserName": "lcy",
                                "Dept": {
                                    "Id": "e8731583-3397-4f28-aa43-c006dbe750a2",
                                    "DeptName": "行政部",
                                    "GroupId": "c875149c-ee0c-48e2-bd2d-39d870f49b67"
                                }
                            },
                            "CreateTime": "1238413000",
                            "StartTime": "1238463000",
                            "EndTime": "1238468400",
                            "Description": " 小东门银行",
                            "IsAudited": false,
                            "AuditUser": { "Name": "王晓" },
                            "AuditNote": "asdasdasd",
                            "AuditTime": "1282010290",
                            "IsForWork": false,
                            "IsAgreed": false
                        },
                         { "Id": "480f88ww36-29a9-4ba6-bbe1-8a3e928fc5de",
                             "LeaveTypeId": "c7615898-2739-4c33-a8dc- a1451537b170",
                             "LeaveTypeName": "外出",
                             "User": {
                                 "Id": "ce36c495-38cc-4b7e-875e-364ff8e087b5",
                                 "Name": "杨欲鑫",
                                 "UserName": "lcy",
                                 "Dept": {
                                     "Id": "e8731583-3397-4f28-aa43-c006dbe750a2",
                                     "DeptName": "行政部",
                                     "GroupId": "c875149c-ee0c-48e2-bd2d-39d870f49b67"
                                 }
                             },
                             "CreateTime": "1238413000",
                             "StartTime": "1238463000",
                             "EndTime": "1238468400",
                             "Description": " 小东门银行",
                             "IsAudited": false,
                             "AuditUser": { "Name": "王晓" },
                             "AuditNote": "asdasdasd",
                             "AuditTime": "1282010290",
                             "IsForWork": false,
                             "IsAgreed": false
                         },
                        { "Id": "480f883ww6-29a9-4ba6-bbe1-8a3e928fc5de",
                            "LeaveTypeId": "c7615898-2739-4c33-a8dc- a1451537b170",
                            "LeaveTypeName": "外出",
                            "User": {
                                "Id": "ce36c495-38cc-4b7e-875e-364ff8e087b5",
                                "Name": "谯虎",
                                "UserName": "lcy",
                                "Dept": {
                                    "Id": "e8731583-3397-4f28-aa43-c006dbe750a2",
                                    "DeptName": "行政部",
                                    "GroupId": "c875149c-ee0c-48e2-bd2d-39d870f49b67"
                                }
                            },
                            "CreateTime": "1238413000",
                            "StartTime": "1238463000",
                            "EndTime": "1238468400",
                            "Description": " 小东门银行",
                            "IsAudited": false,
                            "AuditUser": { "Name": "王晓" },
                            "AuditNote": "asdasdasd",
                            "AuditTime": "1282010290",
                            "IsForWork": false,
                            "IsAgreed": false
                        }
                        ]
        };


        var mockEzAccessor = {
            'getBasicInfo': function () {
                g_Var['currentUser'] = mock_currentUser['Name'];
            },
            'getCurrentTime': function () {
                return new Date();
            },
            'getStartYear': function () {
                return '1999';
            },
            'doUpdateLeaveList': function (isShowAuditedLeave, currentYear, currentMonth) {
                g_Var['leaveInfoList'] = mock_leaveInfoList['leaveInfoList'];
                bindLeaveList(g_Var['leaveInfoList']);
            }
        };

        EzAccessor = mockEzAccessor;
    } else {

        var realEzAccessor = {

            'getBasicInfo': function () {
                //g_Var['currentUser'] = <%=ViewData["CurrentUser"] %>;
            },
            'getCurrentTime': function () {
                //return Date.fromEpoch(<%=ViewData["CurrentTime"] %>);
            },
            'getStartYear': function () {
                //return <%=ViewData["StartYear"] %>;
            },
            'doUpdateLeaveList': function (isShowAuditedLeave, curentYear, currentMonth) {

                $(document).ajaxBusy('begin');
                //与服务器交互
                if (isShowAuditedLeave) {

                    $.getJSON(
                            URL_LEAVE_INFOLIST_FORAUDIT,
                            { 'currentYear': curentYear, 'currentMonth': currentMonth, 'isShowAuditedLeave': isShowAuditedLeave },
                            function (e) {
                                bindLeaveList(e);
                                $(document).ajaxBusy('end');
                            });
                }
                else {

                    $.getJSON(
                            URL_LEAVE_INFOLIST_FORAUDIT,
                            { 'isShowAuditedLeave': isShowAuditedLeave },
                            function (e) {
                                $(document).ajaxBusy('end');
                                bindLeaveList(e);

                            });
                }
            }


        }
        EzAccessor = realEzAccessor;
    }

    function toFullTimeWithoutSecond(time) {

        var dayHour = Date.fromEpoch(time).getHours();
        var dayMinutes = Date.fromEpoch(time).getMinutes();

        if (dayHour < 10) {
            dayHour = "0" + dayHour;
        }

        if (dayMinutes < 10) {
            dayMinutes = "0" + dayMinutes;
        }
        var dayTime = dayHour
                      + ":"
                      + dayMinutes;

        var yearAndMonthTime = Date.fromEpoch(time).toChineseDateFormat();

        return yearAndMonthTime + "&nbsp;" + dayTime;
    }

    function bindLeaveList(LeaveInfoListJson) {

        var data = DataConverterForDataTable.convertData(LeaveInfoListJson, convertor);

        data.bPaginate = false;
        data.bRetrieve = true;
        data.bFilter = false;
        data.bSort = false;
        data.bInfo = false;

        $('#divLeaveInfoList').empty();

        var tblLeaveList = $('<table id="tblLeaveList" class="tbl"/>')
               .appendTo('#divLeaveInfoList');

        $('#tblLeaveList').dataTable(data);
        $('.aLinkClass').click(function () {
            window.location.href = "auditLeave?leaveId=" + this.id;
        })

    }

    function initiLeaveInfoListTable(updateTime) {

        var curentYear = updateTime.getFullYear();
        var currentMonth = updateTime.getMonth() + 1;

        EzAccessor.doUpdateLeaveList(false, curentYear, currentMonth);
    }

    function getYearsList(updateTime) {

        var yearsList = [];
        var currentYear = updateTime.getFullYear();

        var startYear = EzAccessor.getStartYear();

        for (var i = startYear; i <= currentYear; i++) {
            yearsList.push({ "text": i,
                "value": i
            });
        }
        return yearsList;
    }

    function getMonthsList() {

        var monthList = [];

        for (var i = 1; i <= 12; i++) {
            monthList.push({ "text": i,
                "value": i
            });
        }
        return monthList;
    }

    function initiYearSelector(updateTime) {

        var currentYear = updateTime.getFullYear();
        var yearDownList = getYearsList(updateTime);

        $("#yearSelector")
              .comboxBinding(yearDownList, 'text', 'value')
              .val(currentYear);
    }

    function initiMonthSelector(updateTime) {

        var currentMonth = updateTime.getMonth() + 1;
        var monthDownList = getMonthsList();

        $("#monthSelector")
              .comboxBinding(monthDownList, 'text', 'value')
              .val(currentMonth);
    }



    function onSelectedValueChange() {

        var isShowAuditedLeave = $('#chkShowAudited').attr('checked');
        var yearChanged = $('#yearSelector').val();
        var monthChanged = $('#monthSelector').val();
        EzAccessor.doUpdateLeaveList(isShowAuditedLeave, yearChanged, monthChanged);
    }

    function showAuditLeaveCallBack() {
        var isShowAuditedLeave = $('#chkShowAudited').attr('checked');

        if (isShowAuditedLeave) {
            $('#yearSelector')
                    .show()
                    .next("label").show();
            $('#monthSelector')
                    .show()
                    .next("label").show();
        }
        else {
            $('#yearSelector')
                    .hide()
                    .next("label").hide();
            $('#monthSelector')
                    .hide()
                    .next("label").hide();
        }

        var currentYear = $('#yearSelector').val();
        var currentMonth = $('#monthSelector').val();

        EzAccessor.doUpdateLeaveList(isShowAuditedLeave, currentYear, currentMonth);
    }



    function initPage() {
        EzTipsManager.addTipBox('#tip_Remind', 'tipRemind');
        EzTipsManager.addTipBox('#tip_isShowAudited', 'tipIsShowAudited');
        EzTipsManager.showTipBox('tipRemind');

        var currentTime = EzAccessor.getCurrentTime();
        $(document).ajaxBusy();
        EzAccessor.getBasicInfo();

        $('#chkShowAudited').attr('checked', '');

        initiLeaveInfoListTable(currentTime);
        initiYearSelector(currentTime);
        initiMonthSelector(currentTime);
    }

    function initPageEvent() {

        $('#lblClicked').click(function () {
            showAuditLeaveCallBack();
        });

        $("#yearSelector").change(function () {
            onSelectedValueChange();
        });

        $("#monthSelector").change(function () {
            onSelectedValueChange();
        });

        $('#lblClicked').click(function () {
            if ($('#chkShowAudited').attr("checked") == true) {
                EzTipsManager.showTipBox('tipIsShowAudited');
            } else {
                EzTipsManager.hideTipBox('tipIsShowAudited');
            }
        });

    }

    $(function () {

        initPage();
        initPageEvent();
    })

</script>
<!-- InstanceEndEditable -->



<body>
<div id="root">
	<div id="headw">
    	<div id="head">
            <!-- InstanceBeginEditable name="pageHead" -->
			<p>
                早上好，杨裕欣(软件工程部)
		    </p>
            <div id="status-bar">
            <span><a href="#">设置</a></span>&nbsp;
            魏玛软件出品
            </div>
            <div id="tabs">
				<ul>
					<li><a class="current">第一栏</a></li>
					<li><a>第一栏</a></li>
					<li><a>第一栏</a></li>
				</ul>
			</div>
            <!-- InstanceEndEditable -->
        </div>
    </div>
    <div id="main">
    
    	<div id="contentw">
            <div id="content-page">
	            <!-- InstanceBeginEditable name="pageContent" -->
                    <div id="page-head">
                        <label id="lblClicked" for="chkShowAudited">
                            <input type="checkbox" id="chkShowAudited" />显示已审核的假期申请</label>
                    </div>
                    <div id="page-body">
                        <div id="divLeaveInfoList">
                        </div>
                    </div>
            <!-- InstanceEndEditable -->
            </div>
            <div id="content-foot"><small>这个是内容下面的脚注</small></div>
        </div>        
        
        <div id="tipsw">
	        <!-- InstanceBeginEditable name="pageShortcut" -->
        
            <!-- InstanceEndEditable -->            
            
            <div id="tips" class="box">
           	
            </div>
        </div>
        <div class="clearfloat"></div>
    </div> 
</div>
	    <!-- InstanceBeginEditable name="pageFoot" -->
    <div id="tip_Remind" style="display: none;">
        <h1>
            小贴士：</h1>
        <p id="receiver" class="indent">
            您可以通过改变"显示已审核的假期申请"选择器的状态，用来选择是否显示已经通过审核的假期申请。
        </p>
    </div>
    <div id="tip_isShowAudited" style="display: none;" class="tip-info">
        <h1>
            显示已审核的假期申请</h1>
    </div>
    <!-- InstanceEndEditable -->    
</body>
<!-- InstanceEnd --></html>
